package com.woniu.aimd.mapper;

import com.woniu.aimd.pojo.DTO.NodeBaseInfo;
import com.woniu.aimd.pojo.entity.Node;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface NodeMapper {

    /**
     * @Description: 增加笔记
     * @return: boolean
     * @Author:  zcnovice
     * @date:  2025/6/10 上午12:27
     */
    boolean insert(Node node);

    //删除
    /**
     * @Description: 根据id删除笔记
     * @return: boolean
     * @Author:  zcnovice
     * @date:  2025/6/10 上午12:31
     */
    boolean delete(String nodeId);

    //修改
    /**
     * @Description: 修改笔记
     * @return: boolean
     * @Author:  zcnovice
     * @date:  2025/6/10 上午12:32
     */
    boolean update(Node node);

    //查询
    @Select("select title,nodeId,content,classId,stage from node " +
            "where classId=#{classId} and stage=#{stage} order by stage asc")
    List<NodeBaseInfo> getNodeInfo(Node node);
    @Select("select distinct stage from node where classId=#{classId} order by stage asc")
    List<Integer> getStagesByClassId(String classId);

    //根据Id取文档
    @Select("select title,nodeId,content,stage,classId from node where nodeId = #{nodeId} " )
    Node getNodeById(String nodeId);
    @Select("select title,nodeId,content,stage,classId " +
            "from node where  title like concat('%',#{title},'%') and classId = #{classId}")
    Node getNodeByTitle(@Param("title")String title,@Param("classId") String classId);
}
